package main

import (
	"fmt"
	"unsafe"
)

// 常量用来定义枚举
// 数字 0、1 和 2 分别代表未知性别、女性和男性。
const (
	Unknow = 0
	Female = 1
	Male   = 2
)

const (
	a = "abc"
	b = len(a)
	c = unsafe.Sizeof(a)
)

// 使用iota
const (
	Apple = iota + 1
	Banana
	Cherimoya
	Durian
	Elderberry
	Fig
)

type ByteSize float64

const (
	_           = iota
	KB ByteSize = 1 << (10 * iota)
	MB
	GB
	TB
	PB
	EB
	ZB
	YB
)

func main() {
	const length int = 10
	fmt.Println("length=", length)
	//常量不能重新赋值 cannot assign to length (constant 10 of type int)
	//length = 100

	println(a, b, c)
	println(Apple, Banana, Cherimoya, Durian, Elderberry, Fig)
	println(KB, MB, GB, TB, PB, EB, ZB, YB)

}
